import React, { useState, useEffect } from 'react'
import { useNavigate } from "react-router-dom"
import "../Hcy_scss/Hcy_page2.scss"
import { useDispatch } from 'react-redux'
import { changeDefaultState } from "../../../redux/slice/DefaultSlice"

export default function Hcy_page2() {
  const dispatch = useDispatch()
  let navigate = useNavigate()
  useEffect(() => {
    // 设置定时器，10秒后跳转到另一个页面
    const timer = setTimeout(() => {
      dispatch(changeDefaultState(3))
    }, 10000); // 10秒 = 10000毫秒

    // 清理定时器
    return () => clearTimeout(timer);
  }, []);

  return (
    <div id='Hcy_page2' className="animate__animated animate__bounceInUp">
      <h2>排队中...</h2>
      <p>司机马上接单了，请耐心等待。</p>
      <button onClick={()=>{dispatch(changeDefaultState(4))}}>取消订单</button>
    </div>
  )
}
